//右滑关闭
mui.init({
	swipeBack: true,
})

window.onload = function() {
	mui.plusReady(function() {

		plus.nativeUI.closeWaiting();

	})
}

var UserNO = localStorage.getItem("UserName");
//alert(UserNO);
function showinfo(event) {
	event.preventDefault(); // 阻止默认行为
	change2(1);
}

function openPosition(WorkOrderNO, MaterialNO, WOQty, MaterialName) {




	mui.openWindow({
		url: 'MfgQCmaterial.html',
		action: UserNO,

		extras: {
			WorkOrderNO: WorkOrderNO,
			MaterialNO: MaterialNO,
			WOQty: WOQty,
			MaterialName: MaterialName
		}
		// show: {
		// 	autoShow: false
		// }
	});




	// console.log("'" + urlorder + "'");

}



function change2(e) {

	pageno = e;
	var pageall;
	//$("#all").html("");//全部清空
	var html = "";
	var WorkOrderNO = $("#WorkOrderNO").val();
	var MaterialNO = $("#MaterialNO").val();


	xccpost("JyhstWebASHX.ashx", {
		Action: "GetWorkOrderList",
		PageIndex: e,
		PageSize: 10,
		WorkOrderNO: WorkOrderNO,
		MaterialNO: MaterialNO
	}, function(data) {

		pageall = Math.ceil(parseInt(data.length) / 5) //向上取整    parseInt:转换为INT类型
		if (data.length != null && data.length > 0) {
			$("#all").html(""); ////全部清空
			for (var i = 0; i < data.length; i++) {
				$("#all").append('<li class="mui-table-view-cell" onclick="openPosition(' +
					"'" + data[i].WorkOrderNO + "'," +
					"'" + data[i].MaterialNO + "'," +
					"'" + data[i].WOQty + "'," +
					"'" + data[i].MaterialName + "'" + ')"><p>工单编号：' + data[i].WorkOrderNO +
					' &nbsp;|&nbsp;产品编号: ' + data[i].MaterialNO + '&nbsp;|&nbsp;产品名称：' + data[i]
					.MaterialName + '&nbsp;|&nbsp;工单数量：' + data[i].WOQty +
					'&nbsp;|&nbsp;制单日期：' + data[i].FormDate +
					'</p></li>')

				if (e < 1) {
					e = 1;
					pageno = 1; //就等于第1页 ， 当前页为1
				}
				if (e > pageall) { //如果输入页大于最大页
					e = pageall;
					pageno = pageall; //输入页和当前页都=最大页
				}
				var pageContent = "";
				pageContent += '第<span id=\"a2\">' + pageno + '</span>/';
				pageContent += '<span id="a1">' + pageall + '</span>页';
				/*pageContent +='<span id="a3" >'+ye+'</span>';*/
				if (e > 1) { //页数大于1不能上一页
					pageContent += '<a href="#" onClick="change2(--pageno)" >上一页</a>';
				}
				if (e < pageall) { //页数小于不能上一页
					pageContent += '<a href="#" onClick="change2(++pageno)">下一页</a>';
				}
				if (pageno <= pageall) {
					$("#page").html(pageContent);
				}

			}

		} else {
			$("#all").html("");
			$("#all").html(
				'<a style="font-size:100px; color:#F27D48; display:block; text-align:center;" class="mui-icon mui-icon-search"></a><a class="mui-title" style="color:#808080; position: initial; margin: 0 auto; height:' +
				(window.screen.height - 400) + 'px">暂无数据</a>');
		}
	}, function(errr) {
		mui.toast("网络错误....");
	})



}